package kr.saeildamil.androidstudy.ch08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

public class HandleEvent extends Activity implements View.OnTouchListener {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		/*MyView mv = new MyView(this);
		setContentView(mv);*/
		/*View v = new View(this);
		v.setOnTouchListener(listener);
		setContentView(v);*/
		View v = new View (this);
		v.setOnTouchListener(this);
		setContentView(v);
		
		
	}//end of onCreate

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			Toast.makeText(HandleEvent.this, "x좌표=" + event.getX() + "y좌표=" + event.getY() + "touch", Toast.LENGTH_SHORT).show();
			return true;
		}else if(event.getAction() == MotionEvent.ACTION_UP){
			Toast.makeText(HandleEvent.this, "ACTION_UP", Toast.LENGTH_SHORT).show();
			return true;
		}
		return false;
		
	}//end of onTouch
	
	/*TouchListenerClass listener = new TouchListenerClass();
	
	public class TouchListenerClass implements View.OnTouchListener{

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			
			if(event.getAction() == MotionEvent.ACTION_DOWN){
				Toast.makeText(HandleEvent.this, "x좌표=" + event.getX() + "y좌표=" + event.getY() + "touch", Toast.LENGTH_SHORT).show();
				return true;
			}else if(event.getAction() == MotionEvent.ACTION_UP){
				Toast.makeText(HandleEvent.this, "ACTION_UP", Toast.LENGTH_SHORT).show();
				return true;
			}
			return false;
		}
		
	}*/
	
	
	
	/*public class MyView extends View{

		public MyView(Context context) {
			super(context);
		}

		@Override
		public boolean onTouchEvent(MotionEvent event) {
			super.onTouchEvent(event);
			float x = event.getX();
			float y = event.getY();
			if(event.getAction() == MotionEvent.ACTION_DOWN){
				Toast.makeText(HandleEvent.this, "x좌표=" + x + "y좌표=" + y + "touch", Toast.LENGTH_SHORT).show();
				return true;
			}else if(event.getAction() == MotionEvent.ACTION_UP){
				Toast.makeText(HandleEvent.this, "ACTION_UP", Toast.LENGTH_SHORT).show();
				return true;
			}
			return false;
		}
	}//end of class MyView
*/	
}
